#pragma once

#include"HashTable.h"
namespace zy
{
	template<class K>
	class unordered_set
	{
		struct SetKeyOfT
		{
			const K& operator()(const K& k)
			{
				return k;
			}
		};
	public:
		typedef typename hash_bucket::HashTable<K,const K, SetKeyOfT, hash_bucket::Hash<K>>::iterator iterator;
		typedef typename hash_bucket::HashTable<K,const K, SetKeyOfT, hash_bucket::Hash<K>>::const_iterator const_iterator;

		iterator begin()
		{
			return _hs.begin();
		}
		iterator end()
		{
			return _hs.end();
		}
		const_iterator begin() const
		{
			return _hs.begin();
		}
		const_iterator end() const
		{
			return _hs.end();
		}

		pair<iterator,bool> insert(const K& k)
		{
			return _hs.insert(k);
		}
		iterator find(const K& k)
		{
			return _hs.find(k);
		}
		bool erase(const K& k)
		{
			return _hs.erase(k);
		}
	private:
		hash_bucket::HashTable<K,const K,SetKeyOfT,hash_bucket::Hash<K>> _hs;
	};

	void test_unordered_set1()
	{
		unordered_set<int> s;
		s.insert(1001);
		s.insert(11);
		s.insert(12);
		s.insert(23);
	}
	void test_unordered_set2()
	{
		string s[] = { "sort","left","right" };
		unordered_set<string> st;
		for (auto e : s)
		{
			st.insert(e);
		}
		st.insert("parent");
		st.insert( "parent");
	}
	void test_unordered_set3()
	{
		unordered_set<int> s;
		s.insert(1);
		s.insert(12);
		s.insert(13);
		s.insert(21);

		unordered_set<int>::iterator cit1 = s.begin();
		unordered_set<int>::const_iterator cit2 = s.begin();
	}
}